/**
 * 
 */
package com.ph.shopping.facade.agent.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ph.shopping.common.core.base.BaseService;
import com.ph.shopping.common.core.customenum.ResultEnum;
import com.ph.shopping.common.util.result.Result;
import com.ph.shopping.facade.agent.entity.AgentLevel;
import com.ph.shopping.facade.agent.service.IAgentLevelService;
import com.ph.shopping.facade.mapper.AgentLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @项目：phshopping-service-agent
 *
 * @描述：
 *
 * @作者： 舒豪
 *
 * @创建时间：2017年3月10日
 *
 * @Copyright @2017 by 舒豪
 */
@Component
@Service(version="1.0.0")
public class AgentLevelService extends BaseService implements IAgentLevelService {

    @Autowired
    private AgentLevelMapper agentLevelMapper;


    public Result getAgentLevelList() {
        return getResult(ResultEnum.SUCCESS,agentLevelMapper.selectAll());
    }

    public Result addAgentLevel(AgentLevel agentLevel) {
        Date date=new Date();
        agentLevel.setCreateTime(date);
        agentLevel.setUpdateTime(date);
        agentLevelMapper.insert(agentLevel);
        return getResult(ResultEnum.SUCCESS);
    }

    public Result updateAgentLevel(AgentLevel agentLevel) {
        Date date=new Date();
        agentLevel.setUpdateTime(date);
        agentLevelMapper.updateByPrimaryKeySelective(agentLevel);
        return getResult(ResultEnum.SUCCESS);
    }

    public Result deleteAgentLevel(AgentLevel agentLevel) {
        agentLevelMapper.delete(agentLevel);
        return getResult(ResultEnum.SUCCESS);
    }
}
